import { WeaTools } from 'ecCom';
// import window from '../util';
export const newUrl = '/api/cube/'
export const CallAPI = (url, method, params) => {
    return new Promise((resolve, reject) => {
        WeaTools.callApi(url, method, params).then(({ noRight, ...data }) => {
            if (noRight) {
                // reject();
                // window.weaHistory.push('/main/cube/noright');
                resolve({ noRight, ...data } as any)
            } else {
                resolve(data as any)
            }
        })
    })
}


export const validatePrompt = (params) => {
    return CallAPI(`${newUrl}card/validatePrompt`, "post", params);
}

export const init = (params) => {
    return CallAPI(`${newUrl}card/init`, "get", params);
}




export const initDetailExcelFile = (params) => {
    return CallAPI(`${newUrl}card/initDetailExcelFile`, "get", params);
}
export const dataInput = (params) => {
    return CallAPI(`${newUrl}card/dataInput`, "get", params);
}
export const fieldAttrAjax = (params) => {
    return CallAPI(`${newUrl}card/fieldAttr`, "get", params);
}

export const likeReply = (params) => {
    return CallAPI(`${newUrl}card/likeReply`, "get", params);
}
export const unlikeReply = (params) => {
    return CallAPI(`${newUrl}card/unlikeReply`, "get", params);
}
export const initReply = (params) => {
    return CallAPI(`${newUrl}new/card/initReply`, "get", params);
}
export const replySubmit = (params) => {
    return CallAPI(`${newUrl}new/card/replySubmit`, "post", params);
}
export const deleteReply = (params) => {
    return CallAPI(`${newUrl}new/card/deleteReply`, "get", params);
}

export const layoutBase = (params) => {
    return CallAPI(`${newUrl}new/card/layoutBase`, "get", params);
}
export const mainFields = (params) => {
    return CallAPI(`${newUrl}new/card/mainFields`, "get", params);
}
export const initDetail = (params) => {
    return CallAPI(`${newUrl}new/card/initDetail`, "get", params);
}
export const getDetailFields = (params) => {
    return CallAPI(`${newUrl}new/card/getDetailFields`, "get", params);
}
export const getDefaultValue = (params) => {
    return CallAPI(`${newUrl}new/card/getDefaultValue`, "get", params);
}
export const getRowColCons = (params) => {
    return CallAPI(`${newUrl}new/card/getRowColCons`, "get", params);
}
export const getTopTabs = (params) => {
    return CallAPI(`${newUrl}new/card/topTabs`, "get", params);
}
export const getInnerTabs = (params) => {
    return CallAPI(`${newUrl}new/card/innerTabs`, "get", params);
}
export const getRightMenus = (params) => {
    return CallAPI(`${newUrl}new/card/rightMenus`, "get", params);
}

export const getInputEntry = (params) => {
    return CallAPI(`${newUrl}new/card/getInputEntry`, "get", params);
}
export const cubeDataInput = (params) => {
    return CallAPI(`${newUrl}new/card/cubeDataInput`, "post", params);
}
export const getLayoutFieldAttr = (params) => {
    return CallAPI(`${newUrl}new/card/getLayoutFieldAttr`, "get", params);
}
export const cubeFieldAttr = (params) => {
    return CallAPI(`${newUrl}new/card/cubeFieldAttr`, "get", params);
}
export const getFieldAttrLinkPage = (params) => {
    return CallAPI(`${newUrl}new/card/getFieldAttrLinkPage`, "get", params);
}
export const getVerifyEntity = (params) => {
    return CallAPI(`${newUrl}new/card/getVerifyEntity`, "get", params);
}
export const cubeVerifyRepeat = (params) => {
    return CallAPI(`${newUrl}new/card/cubeVerifyRepeat`, "post", params);
}

export const doSubmit = (params) => {
    return CallAPI(`${newUrl}new/card/doSubmit`, "post", params);
}
export const checkCardDataChange = (params) => {
    return CallAPI(`${newUrl}new/card/checkCardDataChange`, "post", params);
}
export const reply = (params) => {
    return CallAPI(`${newUrl}new/card/reply`, "get", params);
}

export const getCardLog = (params) => {
    return CallAPI(`/api/formmode/card/modeLog`, "post", params);
}
export const recoverData = (params) => {
    return CallAPI(`/api/formmode/card/recoverData`, "post", params);
}

export const getCardLogDetail = (params) => {
    return CallAPI(`/api/formmode/card/modeLogDetail`, "post", params);
}

export const getDetailFieldLog = (params) => {
    return CallAPI(`/api/formmode/card/getDetailFieldLog`, "get", params);
}
export const getMainFieldLog = (params) => {
    return CallAPI(`/api/formmode/card/getMainFieldLog`, "get", params);
}

export const checkCardRight = (params) => {
    return CallAPI(`${newUrl}new/card/checkCardRight`, "get", params);
}
export const getModeBase = (params) => {
    return CallAPI(`${newUrl}new/card/getModeBase`, "get", params);
}
export const getCubeLikeInfo = (params) => {
    return CallAPI(`${newUrl}new/card/getCubeLikeInfo`, "get", params);
}
export const saveCubeLikeInfo = (params) => {
    return CallAPI(`${newUrl}new/card/saveCubeLikeInfo`, "get", params);
}

export const getQRCode = (params) => {
    return CallAPI(`${newUrl}new/card/getQRCode`, "get", params);
}

export const getBarCode = (params) => {
    return CallAPI(`${newUrl}new/card/getBarCode`, "get", params);
}

export const getIframe = (params) => {
    return CallAPI(`${newUrl}new/card/getIframe`, "get", params);
}

export const getTreeDataUrl = (params) => {
    return CallAPI(`${newUrl}new/card/getTreeDataUrl`, "get", params);
}

export const getWaterMarkImg = (params) => {
    return CallAPI(`${newUrl}setting/waterMarkImg`, "get", params);
}

export const detailImportNew = (params) => {
    return CallAPI(`${newUrl}card/detailImportNew`, "POST", params);
}

export const getCardMarginData = (params) => {
    return CallAPI(`/api/cube/setting/getCardSize`, "GET", params);
}

/**卡片导出excel模板 */
export const doExpCardConfig = (params) => {
    return CallAPI(`/api/cube/mode/mode/doExpCardConfig`, "POST", params);
}

export const doSaveDetailPagesize = (params) => {
    return CallAPI(`/api/cube/new/card/saveDetailPageSize`, "get", params);
}

export const confirmTemplate = (params) => {
    return CallAPI(`/api/cube/new/card/confirmTemplate`, "get", params);
}


export const docustompage = (params) => {
    return WeaTools.callApi('/formmode/request/CustomPageForward.jsp', 'POST', params, 'text');
}

